package com.five.community.controller;

import com.five.community.bean.*;
import com.five.community.bean.vo.ActivityVo;
import com.five.community.bean.vo.BuildingVo;
import com.five.community.bean.vo.RepairVo;
import com.five.community.mapper.ActivityMapper;
import com.five.community.service.*;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class WelcomeController {
    @Autowired
    private RepairService repairService;
    @Autowired
    private ActivityMapper activityMapper;
    @Autowired
    private BuildingService buildingService;
    @Autowired
    private VillageService villageService;
    @Autowired
    private HousingService housingService;
    @Autowired
    private PersonService personService;
    @Autowired
    private ParkingService parkingService;
    @RequestMapping("/welcomeUi")
    public String welcomeUi(ModelMap map){
        try {
            List<Activity> activityVos = activityMapper.selectAll();
            List<BuildingVo> buildingVos = buildingService.selectAll();
            List<RepairVo> repairVos = repairService.selectAll();
            List<Village> villages = villageService.selectAll();
            List<Housing> housings = housingService.selectAll();
            List<Person> persons = personService.selectAll();
            List<Parking> parkings = parkingService.selectAll();
            map.addAttribute("activityVos",activityVos);
            map.addAttribute("buildingVos",buildingVos);
            map.addAttribute("repairVos",repairVos);
            map.addAttribute("villages",villages);
            map.addAttribute("housings",housings);
            map.addAttribute("persons",persons);
            map.addAttribute("parkings",parkings);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return "welcome";
    }

}
